package ClassStudy;

import java.util.Objects;

/**
 * @author Cheng Jun
 * @version 1.0
 * @date 2019/11/19 16:43
 */
public class Student {
    // 测试反射能不能直接修改 final static的变量
    private final static String SCHOOL = "清华大学";

    static {
        System.out.println("加载Studnet");
    }

    public int age = 10;
    private String name;

    public Student(String name) {
        this.name = name;
    }

    private Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Student() {
    }

    private static String chirography() {
        return "楷体大佬";
    }

    public void hello() {
        System.out.println("Hello Class!!!");
    }

    public void empty() {
        int i = 0;
        i = ++i;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Student)) return false;
        Student student = (Student) o;
        return age == student.age && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
}
